the code is so cordial and familiar.
Example 1: "Hello, world!"Hello World as the first tutorial is already a practice in the programming language. We also follow this practice and see how XSLT can be used to show "Hello World". Although this example has no practical use, please do not worry, there are more detailed examples.Step one: Create Hello.xml to enter XML document.
This is a very simple XML document that contains only one node of the XML
Chapter 2: XSLT instances
ArticleAuthor: A Jie
. 1 how to convert XML into XSLT2.2 one instance2.3 Process Analysis2.4 usage of XSLT 2.1 How XSLT converts XML Let's make an interesting example. You have played the Plasticine and press it on different models t
Javax.xml.transform.stream.StreamResult;
Import java.io.*;
public class Transform {
/**
* Performs an XSLT transformation, sending the results
* to System.out.
*/
public static void Main (string[] args) throws Exception {
if (args.length!= 2) {
System.err.println ("Usage:java Transform [xmlfile] [xsltfile]");
System.exit (1);
}
File XmlFile = new file (Args[0]);
File XSLTFile = new file (args[1]); JAXP reads data using the Source interface
Source Xml
languages. We also follow this Convention to see how to use XSLT to display "Hello World ". Although this example has no practical purpose, please do not worry. There are more detailed examples later.
Step 1: Create the hello. xml file to be entered.
This is a simple XML document that contains only one node's XML structure tree.
Step 2: Create the XSLT document hello. XSL. Tip: the default extension of th
1.XSLT Concept 1.1 What is XSLT 1.2 Why use XSLT 1.3 XSLT's history 1.4 What is XPath 1.5 xslt and CSS comparison 1.6 xslt and IE5 br> 1.XSLT Concept Let's first clarify a concept, you may have heard of the XSL (extensib
Concept
OutlineThis article is divided into five chapters: the XSLT concept, the XSLT instance, the XSLT element syntax, the XPath syntax, and the XSLT resource.The concept of 1.XSLT1.1 What is XSLT1.2 Why do you use XSLTThe history of 1.3 XSLT1.4 What is XPath1.5 XSLT and
The concept of 1.XSLT
1.1 What is XSLT
1.2 Why do you use XSLT
The history of 1.3 XSLT
1.4 What is XPath
1.5 XSLT and CSS comparisons
1.6 XSLT and IE5
The concept of 1.XSLT
Let'
With the introduction of the previous two chapters, we have some understanding of the basic concepts of XSLT and its transformation process. Let's learn the specific syntax of XSLT together. When it comes to grammar, it's always boring, and you can go through it in general, and then look at it when you really need to use XSLT.element syntax for 3.XSLT3.1 Xsl:template and Xsl:apply-templates3.2 xsl:value-of3
1 minute to quickly generate xslt for Web content extraction, web content xslt
1 minute to quickly generate xslt for Web content extraction. The specific content is as follows:
1. Project Background
In the article "Python real-time web crawler project description", we have said that a general web crawler can save programmers more than half the time. The focus is
With the introduction of the previous two chapters, we have some understanding of the basic concepts of XSLT and its transformation process. Let's learn the specific syntax of XSLT together. When it comes to grammar, it's always boring, and you can go through it in general, and then look at it when you really need to use XSLT.
element syntax for 3.
. Instances of XSLT
2.1 How XSLT Transforms XML
2.2 An instance
2.3 Process Parsing
The purpose of 2.4 XSLT
2.1 How XSLT Transforms XML
Let's make an interesting analogy: you play with the dough, you press it in different molds, you can make the shape you need. If we assume that the XML data document is a big pie
2.3 Process Parsing
If you successfully see the effect, you may want to know the specific meaning of these codes, let us explain in detail: Look at the hello.xsl file
This is the first line of code for a standard XML document, because XSLT itself is also an XML document. The encoding attribute is used to define the encoding used for the document, and iso-8859-1 mainly supports language encoding in Western Europe and North America
Concept
1.5 XSLT and CSS comparisonsCSS can also format XML documents, so why do you need XSLT when you have CSS? Because CSS is a good way to control the output of the style, such as color, font, size, etc., but it has serious limitations, is:(1) CSS cannot reorder elements in a document;(2) CSS can not judge and control which element is displayed, which is not displayed;(3) CSS can not be statistical ca
Introduction: Explore the concept of generating PostScript files from an XML document using XSLT as the programming language compiler, especially when creating an XML layer before postscript®. This article describes the style sheet as the concept of implicit language definitions, the basics of PostScript, and the abstraction layers involved when creating XML to PostScript compilers.
Using XSLT as a compile
5. Appendix: Resources for XSLT ◇ most authoritative web site http://www.w3.org/Style/XSL/ ◇ about standard XSLT1.0 http://www.w3.org/TR/xslt.html XSLT1.1 http://www.w3.org/TR/xslt11/ XPath1.0 http:// www.w3.org/TR/xpath.html ◇ Learning Tutorials http://www.w3schools.com/xsl/ http:// www.wirelessdevnet.com/channels/wap/training/xslt.html http://msdn.microsoft.com/library/default.asp? url=/library/psdk/xmlsdk/xslp8tlx.htm http://www.
Declare an XML string:
String xml = "....";
Declare the XSLT conversion class:
Extends compiledtransform XSLT = new extends compiledtransform ();
Call the XSLT sheet file:
XSLT. Load ("xsltfile1.xslt ");
Convert string to stream type
Textreader TR =
Grammar
3.5 Xsl:choose, Xsl:when and Xsl:otherwise
The XSL:IF syntax does not have an else attribute. If we are going to make multiple choices, we need to use the Xsl:choose/xsl:when/xsl:otherwise series Process Control syntax. For specific use, see the following XSL file example:
No name available
Description: First in the People node to find Name available ".
3.6 Xsl:sort
In XSLT, the elements of an XML sour
this is not a pig
5) xsl: value-of displays the value of the selected node or attribute.
Select sub-node price
Select weight
6) xsl: attribute: construct the attributes of an xml node.
Used to add attributes to a node, for example:
Output
7) xsl: apply-templates application Template
If the xml file structure is complex, you can define multiple templates and then use
The label application template. for xsl: apply-templates, you can specify the select = "xpath"
){...} Catch (transformerexception e ){...}}
The system entry is shown in figure 2.
Figure 2 system portal page of an instance
The system dynamically generates different pages based on user requests. Figure 3 shows the content displayed after logging on as an advanced user.
Figure 3 dynamically generated product list
Summary
This article designs multiple XSLT document components to reduce the com
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.